from django import template
register = template.Library()
 
@register.filter(name="difficulty_name")  # name 是 html 中的过滤器名
def difficulty_name(difficulty):
    if difficulty=='1':
        return '容易'
    elif difficulty=='2':
        return '一般'
    else:
        return "困难"